import DateUtils from './date'
import Decimal  from 'decimal.js'

export function divTenThousand(val) {
    if (val && typeof val !== 'undefined' && val !== null && Number(val) !== 0) {
        return new Decimal(val).div(10000)
    } else {
        return new Decimal('0')
    }
}

/**
 * @LastEditors: Song_Bing_Yan
 * @description: 订单待支付倒计时
 * @param {string} createTime 创建时间
 * @param {string} payTimeOut 倒计时长
 * @returns {*}
 */

const dateTool = new DateUtils()
export function useCountdownTime(startTime, timeOut) {
    if (!timeOut) return 0
    Number(timeOut) * 1000
    const createDate = dateTool.getTime(startTime)
    const timeDifference = createDate + Number(timeOut) * 1000
    return dateTool.getYMDHMSs(new Date(timeDifference))
}